﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Data.Sql;
using LR4.Models;

namespace LR4.DAO
{
    public class PropertyDAO : DAO
    {
        public bool AddRecordP(Property property) //  Добавление записи в таблицу Property
        {
            bool result = true;
            Connect();

            try
            {
                SqlCommand cmd = new SqlCommand(
                    "INSERT INTO Property (Square, Address, Type_id, Id_f, Details) " +
                    "VALUES (@Square, @Address, @Type_id, @Id_f, @Details)", Connection);

                cmd.Parameters.Add(new SqlParameter("@Square", property.Square));
                cmd.Parameters.Add(new SqlParameter("@Address", property.Address));
                cmd.Parameters.Add(new SqlParameter("@Type_id", property.Type_id));
                cmd.Parameters.Add(new SqlParameter("@Id_f", property.Id_f));
                cmd.Parameters.Add(new SqlParameter("@Details", property.Details));
                cmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                result = false;
            }
            finally
            {
                Disconnect();
            }
            return result;
        }
    }
}
